<!--
描述：办公自动化-待办流程组件
开发人：sunlf
开发日期：2017年8月17日
-->

<template lang='pug'>
  div(style="height:100%;")
    keep-alive
      kalix-table(bizKey='processTask' title='待办流程列表'
        v-bind:targetURL='targetURL'
        v-bind:formModel.sync='formModel'
        v-bind:bizDialog='bizDialog'
        v-bind:isFixedColumn="isFixedColumn"
        bizSearch='TaskSearch'
        v-bind:toolbarBtnList="toolbarBtnList"
        v-bind:isShowToolBar="isShowToolBar"
        v-bind:btnList='btnList' v-bind:customTableTool='customTableTool')
        template(slot="tableColumnSlot")
          kalix-biz-no-column(name="businessNo")
          el-table-column(prop="title" label="业务名称" width="280" align="center")
          el-table-column(prop="name" label="任务名称" align="center")
          el-table-column(prop="description" label="描述" align="center")
          el-table-column(prop="createTime" label="创建时间" align="center")
    kalix-task-view(ref="kalixDialog")
    kalix-task-complete(ref="kalixTaskDialog")
</template>

<script type='text/ecmascript-6'>
  // import BaseTable from '@/components/custom/baseTable'
  import {TaskURL} from '../config.toml'
  import {taskBtnList} from './config'
  // import {registerComp} from '../comp'
  import BizNoColumn from '../comp/bizNoColumn'
  // import Vue from 'vue'
  // import BaseTableTool from '@/components/custom/baseTableTool'
  // import EventBus from 'common/eventbus'
  // import {ON_INIT_DIALOG_DATA} from '@/components/custom/event.toml'
  import TaskView from '../comp/taskView'
  import TaskComplete from '../comp/taskComplete'

  // Vue.component('TaskSearch', require('./taskSearch').default)

  export default {
    name: 'kalix-oa-task',
    activated() {
      console.log(this.bizKey + '  is activated')
    },
    deactivated() {
      console.log(this.bizKey + '  is deactivated')
    },
    filters: {},
    data() {
      return {
        isFixedColumn: true,
        isShowToolBar: false,  // 不显示工具栏
        toolbarBtnList: [{id: 'add', isShow: false},
          {id: 'customBtn1', icon: 'icon-edit', title: '自定义按钮 1', isShow: false},
          {id: 'customBtn2', icon: 'icon-edit', title: '自定义按钮 2', isShow: false},
          {id: 'customBtn3', icon: 'icon-edit', title: '自定义按钮 3', isShow: false},
          {id: 'customBtn4', icon: 'icon-edit', title: '自定义按钮 4', isShow: false}],
        bizKey: 'taskComplete',
        btnList: taskBtnList,
        targetURL: TaskURL,
        bizDialog: [
          {id: 'view', dialog: 'OaTaskView'},
          {id: 'complete', dialog: 'OaTaskComplete'}
        ],
        formModel: {}
      }
    },
    created() {
    },
    mounted() {
      // registerComp()
    },
    filter: {},
    methods: {
      customTableTool(row, btnId) {
        switch (btnId) {
          case 'viewTask': { // 待办功能，未实行
            this.$KalixEventBus.$emit('processTask' + '-' + this.$KalixEventConfig.ON_INIT_DIALOG_DATA, row)
            this.$refs.kalixDialog.$refs.kalixBizDialog.open('查看')
            break
          }
          case 'complete': {
            this.$KalixEventBus.$emit(this.bizKey + '-' + this.$KalixEventConfig.ON_INIT_DIALOG_DATA, row)
            this.$refs.kalixTaskDialog.open(row)
            break
          }
        }
      }
    },
    components: {
      // BaseTable,
      KalixTaskView: TaskView,
      KalixTaskComplete: TaskComplete,
      // KalixTableTool: BaseTableTool,
      KalixBizNoColumn: BizNoColumn
    }
  }
</script>

<style scoped lang='stylus'>

</style>
